﻿namespace MagicWorld.OOP.Model
{
    /// <summary>
    /// 怪兽
    /// </summary>
    public abstract class Monster
    {
        public Monster(long health)
        {
            Health = health;
        }

        /// <summary>
        /// 血量
        /// </summary>
        public long Health { get; set; }

        /// <summary>
        /// 承受伤害
        /// </summary>
        /// <param name="weapon"></param>
        /// <param name="player"></param>
        public virtual void ReceiveDamageBy(Weapon weapon, Player player)
        {
            // 基础规则
            Health -= weapon.Damage;
        }
    }

    /// <summary>
    /// 兽人
    /// </summary>
    public class Orc : Monster
    {
        public Orc(long health) : base(health)
        {
        }

        public override void ReceiveDamageBy(Weapon weapon, Player player)
        {
            if (weapon.DamageType == DamageType.Physical)
            {
                // Orc 的物理防御规则
                Health = Health - weapon.Damage / 2;
            }
            else
            {
                base.ReceiveDamageBy(weapon, player);
            }
        }
    }

    /// <summary>
    /// 精灵
    /// </summary>
    public class Elf : Monster
    {
        public Elf(long health) : base(health)
        {
        }

        public override void ReceiveDamageBy(Weapon weapon, Player player)
        {
            if (weapon.DamageType == DamageType.Fire || weapon.DamageType == DamageType.Ice)
            {
                // Orc 的物理防御规则
                Health = Health - weapon.Damage / 2;
            }
            else
            {
                base.ReceiveDamageBy(weapon, player);
            }
        }
    }

    /// <summary>
    /// 龙
    /// </summary>
    public class Dragoon : Monster
    {
        public Dragoon(long health) : base(health)
        {
        }

        public override void ReceiveDamageBy(Weapon weapon, Player player)
        {
            if (player is DragonKnight)
            {
                Health = Health - weapon.Damage * 2;
            }
        }
    }
}